
_init:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
char *argv[] = { "sh", 0 };

int child_id;

int main(void)
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	83 e4 f0             	and    $0xfffffff0,%esp
   6:	83 ec 20             	sub    $0x20,%esp
  int pid, wpid;

  if(open("console", O_RDWR) < 0){
   9:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  10:	00 
  11:	c7 04 24 3e 09 00 00 	movl   $0x93e,(%esp)
  18:	e8 23 04 00 00       	call   440 <open>
  1d:	85 c0                	test   %eax,%eax
  1f:	79 30                	jns    51 <main+0x51>
    mknod("console", 1, 1);
  21:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  28:	00 
  29:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  30:	00 
  31:	c7 04 24 3e 09 00 00 	movl   $0x93e,(%esp)
  38:	e8 0b 04 00 00       	call   448 <mknod>
    open("console", O_RDWR);
  3d:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  44:	00 
  45:	c7 04 24 3e 09 00 00 	movl   $0x93e,(%esp)
  4c:	e8 ef 03 00 00       	call   440 <open>
  }
  dup(0);  // stdout
  51:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  58:	e8 1b 04 00 00       	call   478 <dup>
  dup(0);  // stderr
  5d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  64:	e8 0f 04 00 00       	call   478 <dup>
  69:	eb 01                	jmp    6c <main+0x6c>
    printf(1,"[init]\twait\n" );
    //if(pid > 0) wait();
    //fork();
    while((wpid=wait()) >= 0 && wpid != pid)
      printf(1, "zombie!\n");
  }
  6b:	90                   	nop
  }
  dup(0);  // stdout
  dup(0);  // stderr

  for(;;){
    printf(1, "init: starting sh\n");
  6c:	c7 44 24 04 46 09 00 	movl   $0x946,0x4(%esp)
  73:	00 
  74:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  7b:	e8 f7 04 00 00       	call   577 <printf>
    pid = fork();
  80:	e8 73 03 00 00       	call   3f8 <fork>
  85:	89 44 24 1c          	mov    %eax,0x1c(%esp)
    if(pid > 0)
  89:	83 7c 24 1c 00       	cmpl   $0x0,0x1c(%esp)
  8e:	7e 25                	jle    b5 <main+0xb5>
    {
      printf(1,"[init]\tchild pid = %d\n",pid);
  90:	8b 44 24 1c          	mov    0x1c(%esp),%eax
  94:	89 44 24 08          	mov    %eax,0x8(%esp)
  98:	c7 44 24 04 59 09 00 	movl   $0x959,0x4(%esp)
  9f:	00 
  a0:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  a7:	e8 cb 04 00 00       	call   577 <printf>
      child_id = pid;
  ac:	8b 44 24 1c          	mov    0x1c(%esp),%eax
  b0:	a3 40 0c 00 00       	mov    %eax,0xc40

    }
    
    if(pid < 0){
  b5:	83 7c 24 1c 00       	cmpl   $0x0,0x1c(%esp)
  ba:	79 19                	jns    d5 <main+0xd5>
      printf(1, "init: fork failed\n");
  bc:	c7 44 24 04 70 09 00 	movl   $0x970,0x4(%esp)
  c3:	00 
  c4:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  cb:	e8 a7 04 00 00       	call   577 <printf>
      exit();
  d0:	e8 2b 03 00 00       	call   400 <exit>
    }
    if(pid == 0){
  d5:	83 7c 24 1c 00       	cmpl   $0x0,0x1c(%esp)
  da:	75 72                	jne    14e <main+0x14e>
      printf(1,"[init]\tchild_id = %d\n", child_id);
  dc:	a1 40 0c 00 00       	mov    0xc40,%eax
  e1:	89 44 24 08          	mov    %eax,0x8(%esp)
  e5:	c7 44 24 04 83 09 00 	movl   $0x983,0x4(%esp)
  ec:	00 
  ed:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  f4:	e8 7e 04 00 00       	call   577 <printf>
      if(getpid() == child_id) 
  f9:	e8 82 03 00 00       	call   480 <getpid>
  fe:	8b 15 40 0c 00 00    	mov    0xc40,%edx
 104:	39 d0                	cmp    %edx,%eax
 106:	75 19                	jne    121 <main+0x121>
      {
        printf(1,"i'm child 1\n" );
 108:	c7 44 24 04 99 09 00 	movl   $0x999,0x4(%esp)
 10f:	00 
 110:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 117:	e8 5b 04 00 00       	call   577 <printf>
        exit();
 11c:	e8 df 02 00 00       	call   400 <exit>
      } 
      else
      {
        exec("sh", argv);
 121:	c7 44 24 04 18 0c 00 	movl   $0xc18,0x4(%esp)
 128:	00 
 129:	c7 04 24 3b 09 00 00 	movl   $0x93b,(%esp)
 130:	e8 03 03 00 00       	call   438 <exec>
        printf(1, "init: exec sh failed\n");
 135:	c7 44 24 04 a6 09 00 	movl   $0x9a6,0x4(%esp)
 13c:	00 
 13d:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 144:	e8 2e 04 00 00       	call   577 <printf>
        exit();
 149:	e8 b2 02 00 00       	call   400 <exit>
      }
      
    }
    printf(1,"[init]\twait\n" );
 14e:	c7 44 24 04 bc 09 00 	movl   $0x9bc,0x4(%esp)
 155:	00 
 156:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 15d:	e8 15 04 00 00       	call   577 <printf>
    //if(pid > 0) wait();
    //fork();
    while((wpid=wait()) >= 0 && wpid != pid)
 162:	eb 14                	jmp    178 <main+0x178>
      printf(1, "zombie!\n");
 164:	c7 44 24 04 c9 09 00 	movl   $0x9c9,0x4(%esp)
 16b:	00 
 16c:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 173:	e8 ff 03 00 00       	call   577 <printf>
      
    }
    printf(1,"[init]\twait\n" );
    //if(pid > 0) wait();
    //fork();
    while((wpid=wait()) >= 0 && wpid != pid)
 178:	e8 8b 02 00 00       	call   408 <wait>
 17d:	89 44 24 18          	mov    %eax,0x18(%esp)
 181:	83 7c 24 18 00       	cmpl   $0x0,0x18(%esp)
 186:	0f 88 df fe ff ff    	js     6b <main+0x6b>
 18c:	8b 44 24 18          	mov    0x18(%esp),%eax
 190:	3b 44 24 1c          	cmp    0x1c(%esp),%eax
 194:	75 ce                	jne    164 <main+0x164>
      printf(1, "zombie!\n");
  }
 196:	e9 d0 fe ff ff       	jmp    6b <main+0x6b>
 19b:	90                   	nop

0000019c <stosb>:
               "cc");
}

static inline void
stosb(void *addr, int data, int cnt)
{
 19c:	55                   	push   %ebp
 19d:	89 e5                	mov    %esp,%ebp
 19f:	57                   	push   %edi
 1a0:	53                   	push   %ebx
  asm volatile("cld; rep stosb" :
 1a1:	8b 4d 08             	mov    0x8(%ebp),%ecx
 1a4:	8b 55 10             	mov    0x10(%ebp),%edx
 1a7:	8b 45 0c             	mov    0xc(%ebp),%eax
 1aa:	89 cb                	mov    %ecx,%ebx
 1ac:	89 df                	mov    %ebx,%edi
 1ae:	89 d1                	mov    %edx,%ecx
 1b0:	fc                   	cld    
 1b1:	f3 aa                	rep stos %al,%es:(%edi)
 1b3:	89 ca                	mov    %ecx,%edx
 1b5:	89 fb                	mov    %edi,%ebx
 1b7:	89 5d 08             	mov    %ebx,0x8(%ebp)
 1ba:	89 55 10             	mov    %edx,0x10(%ebp)
               "=D" (addr), "=c" (cnt) :
               "0" (addr), "1" (cnt), "a" (data) :
               "memory", "cc");
}
 1bd:	5b                   	pop    %ebx
 1be:	5f                   	pop    %edi
 1bf:	5d                   	pop    %ebp
 1c0:	c3                   	ret    

000001c1 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 1c1:	55                   	push   %ebp
 1c2:	89 e5                	mov    %esp,%ebp
 1c4:	83 ec 10             	sub    $0x10,%esp
  char *os;

  os = s;
 1c7:	8b 45 08             	mov    0x8(%ebp),%eax
 1ca:	89 45 fc             	mov    %eax,-0x4(%ebp)
  while((*s++ = *t++) != 0)
 1cd:	90                   	nop
 1ce:	8b 45 0c             	mov    0xc(%ebp),%eax
 1d1:	0f b6 10             	movzbl (%eax),%edx
 1d4:	8b 45 08             	mov    0x8(%ebp),%eax
 1d7:	88 10                	mov    %dl,(%eax)
 1d9:	8b 45 08             	mov    0x8(%ebp),%eax
 1dc:	0f b6 00             	movzbl (%eax),%eax
 1df:	84 c0                	test   %al,%al
 1e1:	0f 95 c0             	setne  %al
 1e4:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 1e8:	83 45 0c 01          	addl   $0x1,0xc(%ebp)
 1ec:	84 c0                	test   %al,%al
 1ee:	75 de                	jne    1ce <strcpy+0xd>
    ;
  return os;
 1f0:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
 1f3:	c9                   	leave  
 1f4:	c3                   	ret    

000001f5 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 1f5:	55                   	push   %ebp
 1f6:	89 e5                	mov    %esp,%ebp
  while(*p && *p == *q)
 1f8:	eb 08                	jmp    202 <strcmp+0xd>
    p++, q++;
 1fa:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 1fe:	83 45 0c 01          	addl   $0x1,0xc(%ebp)
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 202:	8b 45 08             	mov    0x8(%ebp),%eax
 205:	0f b6 00             	movzbl (%eax),%eax
 208:	84 c0                	test   %al,%al
 20a:	74 10                	je     21c <strcmp+0x27>
 20c:	8b 45 08             	mov    0x8(%ebp),%eax
 20f:	0f b6 10             	movzbl (%eax),%edx
 212:	8b 45 0c             	mov    0xc(%ebp),%eax
 215:	0f b6 00             	movzbl (%eax),%eax
 218:	38 c2                	cmp    %al,%dl
 21a:	74 de                	je     1fa <strcmp+0x5>
    p++, q++;
  return (uchar)*p - (uchar)*q;
 21c:	8b 45 08             	mov    0x8(%ebp),%eax
 21f:	0f b6 00             	movzbl (%eax),%eax
 222:	0f b6 d0             	movzbl %al,%edx
 225:	8b 45 0c             	mov    0xc(%ebp),%eax
 228:	0f b6 00             	movzbl (%eax),%eax
 22b:	0f b6 c0             	movzbl %al,%eax
 22e:	89 d1                	mov    %edx,%ecx
 230:	29 c1                	sub    %eax,%ecx
 232:	89 c8                	mov    %ecx,%eax
}
 234:	5d                   	pop    %ebp
 235:	c3                   	ret    

00000236 <strlen>:

uint
strlen(char *s)
{
 236:	55                   	push   %ebp
 237:	89 e5                	mov    %esp,%ebp
 239:	83 ec 10             	sub    $0x10,%esp
  int n;

  for(n = 0; s[n]; n++)
 23c:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)
 243:	eb 04                	jmp    249 <strlen+0x13>
 245:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
 249:	8b 45 fc             	mov    -0x4(%ebp),%eax
 24c:	03 45 08             	add    0x8(%ebp),%eax
 24f:	0f b6 00             	movzbl (%eax),%eax
 252:	84 c0                	test   %al,%al
 254:	75 ef                	jne    245 <strlen+0xf>
    ;
  return n;
 256:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
 259:	c9                   	leave  
 25a:	c3                   	ret    

0000025b <memset>:

void*
memset(void *dst, int c, uint n)
{
 25b:	55                   	push   %ebp
 25c:	89 e5                	mov    %esp,%ebp
 25e:	83 ec 0c             	sub    $0xc,%esp
  stosb(dst, c, n);
 261:	8b 45 10             	mov    0x10(%ebp),%eax
 264:	89 44 24 08          	mov    %eax,0x8(%esp)
 268:	8b 45 0c             	mov    0xc(%ebp),%eax
 26b:	89 44 24 04          	mov    %eax,0x4(%esp)
 26f:	8b 45 08             	mov    0x8(%ebp),%eax
 272:	89 04 24             	mov    %eax,(%esp)
 275:	e8 22 ff ff ff       	call   19c <stosb>
  return dst;
 27a:	8b 45 08             	mov    0x8(%ebp),%eax
}
 27d:	c9                   	leave  
 27e:	c3                   	ret    

0000027f <strchr>:

char*
strchr(const char *s, char c)
{
 27f:	55                   	push   %ebp
 280:	89 e5                	mov    %esp,%ebp
 282:	83 ec 04             	sub    $0x4,%esp
 285:	8b 45 0c             	mov    0xc(%ebp),%eax
 288:	88 45 fc             	mov    %al,-0x4(%ebp)
  for(; *s; s++)
 28b:	eb 14                	jmp    2a1 <strchr+0x22>
    if(*s == c)
 28d:	8b 45 08             	mov    0x8(%ebp),%eax
 290:	0f b6 00             	movzbl (%eax),%eax
 293:	3a 45 fc             	cmp    -0x4(%ebp),%al
 296:	75 05                	jne    29d <strchr+0x1e>
      return (char*)s;
 298:	8b 45 08             	mov    0x8(%ebp),%eax
 29b:	eb 13                	jmp    2b0 <strchr+0x31>
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 29d:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 2a1:	8b 45 08             	mov    0x8(%ebp),%eax
 2a4:	0f b6 00             	movzbl (%eax),%eax
 2a7:	84 c0                	test   %al,%al
 2a9:	75 e2                	jne    28d <strchr+0xe>
    if(*s == c)
      return (char*)s;
  return 0;
 2ab:	b8 00 00 00 00       	mov    $0x0,%eax
}
 2b0:	c9                   	leave  
 2b1:	c3                   	ret    

000002b2 <gets>:

char*
gets(char *buf, int max)
{
 2b2:	55                   	push   %ebp
 2b3:	89 e5                	mov    %esp,%ebp
 2b5:	83 ec 28             	sub    $0x28,%esp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 2b8:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
 2bf:	eb 44                	jmp    305 <gets+0x53>
    cc = read(0, &c, 1);
 2c1:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 2c8:	00 
 2c9:	8d 45 ef             	lea    -0x11(%ebp),%eax
 2cc:	89 44 24 04          	mov    %eax,0x4(%esp)
 2d0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 2d7:	e8 3c 01 00 00       	call   418 <read>
 2dc:	89 45 f0             	mov    %eax,-0x10(%ebp)
    if(cc < 1)
 2df:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
 2e3:	7e 2d                	jle    312 <gets+0x60>
      break;
    buf[i++] = c;
 2e5:	8b 45 f4             	mov    -0xc(%ebp),%eax
 2e8:	03 45 08             	add    0x8(%ebp),%eax
 2eb:	0f b6 55 ef          	movzbl -0x11(%ebp),%edx
 2ef:	88 10                	mov    %dl,(%eax)
 2f1:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
    if(c == '\n' || c == '\r')
 2f5:	0f b6 45 ef          	movzbl -0x11(%ebp),%eax
 2f9:	3c 0a                	cmp    $0xa,%al
 2fb:	74 16                	je     313 <gets+0x61>
 2fd:	0f b6 45 ef          	movzbl -0x11(%ebp),%eax
 301:	3c 0d                	cmp    $0xd,%al
 303:	74 0e                	je     313 <gets+0x61>
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 305:	8b 45 f4             	mov    -0xc(%ebp),%eax
 308:	83 c0 01             	add    $0x1,%eax
 30b:	3b 45 0c             	cmp    0xc(%ebp),%eax
 30e:	7c b1                	jl     2c1 <gets+0xf>
 310:	eb 01                	jmp    313 <gets+0x61>
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
 312:	90                   	nop
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
 313:	8b 45 f4             	mov    -0xc(%ebp),%eax
 316:	03 45 08             	add    0x8(%ebp),%eax
 319:	c6 00 00             	movb   $0x0,(%eax)
  return buf;
 31c:	8b 45 08             	mov    0x8(%ebp),%eax
}
 31f:	c9                   	leave  
 320:	c3                   	ret    

00000321 <stat>:

int
stat(char *n, struct stat *st)
{
 321:	55                   	push   %ebp
 322:	89 e5                	mov    %esp,%ebp
 324:	83 ec 28             	sub    $0x28,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 327:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 32e:	00 
 32f:	8b 45 08             	mov    0x8(%ebp),%eax
 332:	89 04 24             	mov    %eax,(%esp)
 335:	e8 06 01 00 00       	call   440 <open>
 33a:	89 45 f4             	mov    %eax,-0xc(%ebp)
  if(fd < 0)
 33d:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 341:	79 07                	jns    34a <stat+0x29>
    return -1;
 343:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
 348:	eb 23                	jmp    36d <stat+0x4c>
  r = fstat(fd, st);
 34a:	8b 45 0c             	mov    0xc(%ebp),%eax
 34d:	89 44 24 04          	mov    %eax,0x4(%esp)
 351:	8b 45 f4             	mov    -0xc(%ebp),%eax
 354:	89 04 24             	mov    %eax,(%esp)
 357:	e8 fc 00 00 00       	call   458 <fstat>
 35c:	89 45 f0             	mov    %eax,-0x10(%ebp)
  close(fd);
 35f:	8b 45 f4             	mov    -0xc(%ebp),%eax
 362:	89 04 24             	mov    %eax,(%esp)
 365:	e8 be 00 00 00       	call   428 <close>
  return r;
 36a:	8b 45 f0             	mov    -0x10(%ebp),%eax
}
 36d:	c9                   	leave  
 36e:	c3                   	ret    

0000036f <atoi>:

int
atoi(const char *s)
{
 36f:	55                   	push   %ebp
 370:	89 e5                	mov    %esp,%ebp
 372:	83 ec 10             	sub    $0x10,%esp
  int n;

  n = 0;
 375:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)
  while('0' <= *s && *s <= '9')
 37c:	eb 23                	jmp    3a1 <atoi+0x32>
    n = n*10 + *s++ - '0';
 37e:	8b 55 fc             	mov    -0x4(%ebp),%edx
 381:	89 d0                	mov    %edx,%eax
 383:	c1 e0 02             	shl    $0x2,%eax
 386:	01 d0                	add    %edx,%eax
 388:	01 c0                	add    %eax,%eax
 38a:	89 c2                	mov    %eax,%edx
 38c:	8b 45 08             	mov    0x8(%ebp),%eax
 38f:	0f b6 00             	movzbl (%eax),%eax
 392:	0f be c0             	movsbl %al,%eax
 395:	01 d0                	add    %edx,%eax
 397:	83 e8 30             	sub    $0x30,%eax
 39a:	89 45 fc             	mov    %eax,-0x4(%ebp)
 39d:	83 45 08 01          	addl   $0x1,0x8(%ebp)
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 3a1:	8b 45 08             	mov    0x8(%ebp),%eax
 3a4:	0f b6 00             	movzbl (%eax),%eax
 3a7:	3c 2f                	cmp    $0x2f,%al
 3a9:	7e 0a                	jle    3b5 <atoi+0x46>
 3ab:	8b 45 08             	mov    0x8(%ebp),%eax
 3ae:	0f b6 00             	movzbl (%eax),%eax
 3b1:	3c 39                	cmp    $0x39,%al
 3b3:	7e c9                	jle    37e <atoi+0xf>
    n = n*10 + *s++ - '0';
  return n;
 3b5:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
 3b8:	c9                   	leave  
 3b9:	c3                   	ret    

000003ba <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 3ba:	55                   	push   %ebp
 3bb:	89 e5                	mov    %esp,%ebp
 3bd:	83 ec 10             	sub    $0x10,%esp
  char *dst, *src;
  
  dst = vdst;
 3c0:	8b 45 08             	mov    0x8(%ebp),%eax
 3c3:	89 45 fc             	mov    %eax,-0x4(%ebp)
  src = vsrc;
 3c6:	8b 45 0c             	mov    0xc(%ebp),%eax
 3c9:	89 45 f8             	mov    %eax,-0x8(%ebp)
  while(n-- > 0)
 3cc:	eb 13                	jmp    3e1 <memmove+0x27>
    *dst++ = *src++;
 3ce:	8b 45 f8             	mov    -0x8(%ebp),%eax
 3d1:	0f b6 10             	movzbl (%eax),%edx
 3d4:	8b 45 fc             	mov    -0x4(%ebp),%eax
 3d7:	88 10                	mov    %dl,(%eax)
 3d9:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
 3dd:	83 45 f8 01          	addl   $0x1,-0x8(%ebp)
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 3e1:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
 3e5:	0f 9f c0             	setg   %al
 3e8:	83 6d 10 01          	subl   $0x1,0x10(%ebp)
 3ec:	84 c0                	test   %al,%al
 3ee:	75 de                	jne    3ce <memmove+0x14>
    *dst++ = *src++;
  return vdst;
 3f0:	8b 45 08             	mov    0x8(%ebp),%eax
}
 3f3:	c9                   	leave  
 3f4:	c3                   	ret    
 3f5:	90                   	nop
 3f6:	90                   	nop
 3f7:	90                   	nop

000003f8 <fork>:
  name: \
    movl $SYS_ ## name, %eax; \
    int $T_SYSCALL; \
    ret

SYSCALL(fork)
 3f8:	b8 01 00 00 00       	mov    $0x1,%eax
 3fd:	cd 40                	int    $0x40
 3ff:	c3                   	ret    

00000400 <exit>:
SYSCALL(exit)
 400:	b8 02 00 00 00       	mov    $0x2,%eax
 405:	cd 40                	int    $0x40
 407:	c3                   	ret    

00000408 <wait>:
SYSCALL(wait)
 408:	b8 03 00 00 00       	mov    $0x3,%eax
 40d:	cd 40                	int    $0x40
 40f:	c3                   	ret    

00000410 <pipe>:
SYSCALL(pipe)
 410:	b8 04 00 00 00       	mov    $0x4,%eax
 415:	cd 40                	int    $0x40
 417:	c3                   	ret    

00000418 <read>:
SYSCALL(read)
 418:	b8 05 00 00 00       	mov    $0x5,%eax
 41d:	cd 40                	int    $0x40
 41f:	c3                   	ret    

00000420 <write>:
SYSCALL(write)
 420:	b8 10 00 00 00       	mov    $0x10,%eax
 425:	cd 40                	int    $0x40
 427:	c3                   	ret    

00000428 <close>:
SYSCALL(close)
 428:	b8 15 00 00 00       	mov    $0x15,%eax
 42d:	cd 40                	int    $0x40
 42f:	c3                   	ret    

00000430 <kill>:
SYSCALL(kill)
 430:	b8 06 00 00 00       	mov    $0x6,%eax
 435:	cd 40                	int    $0x40
 437:	c3                   	ret    

00000438 <exec>:
SYSCALL(exec)
 438:	b8 07 00 00 00       	mov    $0x7,%eax
 43d:	cd 40                	int    $0x40
 43f:	c3                   	ret    

00000440 <open>:
SYSCALL(open)
 440:	b8 0f 00 00 00       	mov    $0xf,%eax
 445:	cd 40                	int    $0x40
 447:	c3                   	ret    

00000448 <mknod>:
SYSCALL(mknod)
 448:	b8 11 00 00 00       	mov    $0x11,%eax
 44d:	cd 40                	int    $0x40
 44f:	c3                   	ret    

00000450 <unlink>:
SYSCALL(unlink)
 450:	b8 12 00 00 00       	mov    $0x12,%eax
 455:	cd 40                	int    $0x40
 457:	c3                   	ret    

00000458 <fstat>:
SYSCALL(fstat)
 458:	b8 08 00 00 00       	mov    $0x8,%eax
 45d:	cd 40                	int    $0x40
 45f:	c3                   	ret    

00000460 <link>:
SYSCALL(link)
 460:	b8 13 00 00 00       	mov    $0x13,%eax
 465:	cd 40                	int    $0x40
 467:	c3                   	ret    

00000468 <mkdir>:
SYSCALL(mkdir)
 468:	b8 14 00 00 00       	mov    $0x14,%eax
 46d:	cd 40                	int    $0x40
 46f:	c3                   	ret    

00000470 <chdir>:
SYSCALL(chdir)
 470:	b8 09 00 00 00       	mov    $0x9,%eax
 475:	cd 40                	int    $0x40
 477:	c3                   	ret    

00000478 <dup>:
SYSCALL(dup)
 478:	b8 0a 00 00 00       	mov    $0xa,%eax
 47d:	cd 40                	int    $0x40
 47f:	c3                   	ret    

00000480 <getpid>:
SYSCALL(getpid)
 480:	b8 0b 00 00 00       	mov    $0xb,%eax
 485:	cd 40                	int    $0x40
 487:	c3                   	ret    

00000488 <sbrk>:
SYSCALL(sbrk)
 488:	b8 0c 00 00 00       	mov    $0xc,%eax
 48d:	cd 40                	int    $0x40
 48f:	c3                   	ret    

00000490 <sleep>:
SYSCALL(sleep)
 490:	b8 0d 00 00 00       	mov    $0xd,%eax
 495:	cd 40                	int    $0x40
 497:	c3                   	ret    

00000498 <uptime>:
SYSCALL(uptime)
 498:	b8 0e 00 00 00       	mov    $0xe,%eax
 49d:	cd 40                	int    $0x40
 49f:	c3                   	ret    

000004a0 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
 4a0:	55                   	push   %ebp
 4a1:	89 e5                	mov    %esp,%ebp
 4a3:	83 ec 28             	sub    $0x28,%esp
 4a6:	8b 45 0c             	mov    0xc(%ebp),%eax
 4a9:	88 45 f4             	mov    %al,-0xc(%ebp)
  write(fd, &c, 1);
 4ac:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 4b3:	00 
 4b4:	8d 45 f4             	lea    -0xc(%ebp),%eax
 4b7:	89 44 24 04          	mov    %eax,0x4(%esp)
 4bb:	8b 45 08             	mov    0x8(%ebp),%eax
 4be:	89 04 24             	mov    %eax,(%esp)
 4c1:	e8 5a ff ff ff       	call   420 <write>
}
 4c6:	c9                   	leave  
 4c7:	c3                   	ret    

000004c8 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 4c8:	55                   	push   %ebp
 4c9:	89 e5                	mov    %esp,%ebp
 4cb:	83 ec 48             	sub    $0x48,%esp
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
 4ce:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  if(sgn && xx < 0){
 4d5:	83 7d 14 00          	cmpl   $0x0,0x14(%ebp)
 4d9:	74 17                	je     4f2 <printint+0x2a>
 4db:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
 4df:	79 11                	jns    4f2 <printint+0x2a>
    neg = 1;
 4e1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)
    x = -xx;
 4e8:	8b 45 0c             	mov    0xc(%ebp),%eax
 4eb:	f7 d8                	neg    %eax
 4ed:	89 45 ec             	mov    %eax,-0x14(%ebp)
 4f0:	eb 06                	jmp    4f8 <printint+0x30>
  } else {
    x = xx;
 4f2:	8b 45 0c             	mov    0xc(%ebp),%eax
 4f5:	89 45 ec             	mov    %eax,-0x14(%ebp)
  }

  i = 0;
 4f8:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  do{
    buf[i++] = digits[x % base];
 4ff:	8b 4d 10             	mov    0x10(%ebp),%ecx
 502:	8b 45 ec             	mov    -0x14(%ebp),%eax
 505:	ba 00 00 00 00       	mov    $0x0,%edx
 50a:	f7 f1                	div    %ecx
 50c:	89 d0                	mov    %edx,%eax
 50e:	0f b6 90 20 0c 00 00 	movzbl 0xc20(%eax),%edx
 515:	8d 45 dc             	lea    -0x24(%ebp),%eax
 518:	03 45 f4             	add    -0xc(%ebp),%eax
 51b:	88 10                	mov    %dl,(%eax)
 51d:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
  }while((x /= base) != 0);
 521:	8b 55 10             	mov    0x10(%ebp),%edx
 524:	89 55 d4             	mov    %edx,-0x2c(%ebp)
 527:	8b 45 ec             	mov    -0x14(%ebp),%eax
 52a:	ba 00 00 00 00       	mov    $0x0,%edx
 52f:	f7 75 d4             	divl   -0x2c(%ebp)
 532:	89 45 ec             	mov    %eax,-0x14(%ebp)
 535:	83 7d ec 00          	cmpl   $0x0,-0x14(%ebp)
 539:	75 c4                	jne    4ff <printint+0x37>
  if(neg)
 53b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
 53f:	74 2a                	je     56b <printint+0xa3>
    buf[i++] = '-';
 541:	8d 45 dc             	lea    -0x24(%ebp),%eax
 544:	03 45 f4             	add    -0xc(%ebp),%eax
 547:	c6 00 2d             	movb   $0x2d,(%eax)
 54a:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)

  while(--i >= 0)
 54e:	eb 1b                	jmp    56b <printint+0xa3>
    putc(fd, buf[i]);
 550:	8d 45 dc             	lea    -0x24(%ebp),%eax
 553:	03 45 f4             	add    -0xc(%ebp),%eax
 556:	0f b6 00             	movzbl (%eax),%eax
 559:	0f be c0             	movsbl %al,%eax
 55c:	89 44 24 04          	mov    %eax,0x4(%esp)
 560:	8b 45 08             	mov    0x8(%ebp),%eax
 563:	89 04 24             	mov    %eax,(%esp)
 566:	e8 35 ff ff ff       	call   4a0 <putc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 56b:	83 6d f4 01          	subl   $0x1,-0xc(%ebp)
 56f:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 573:	79 db                	jns    550 <printint+0x88>
    putc(fd, buf[i]);
}
 575:	c9                   	leave  
 576:	c3                   	ret    

00000577 <printf>:

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 577:	55                   	push   %ebp
 578:	89 e5                	mov    %esp,%ebp
 57a:	83 ec 38             	sub    $0x38,%esp
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
 57d:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
  ap = (uint*)(void*)&fmt + 1;
 584:	8d 45 0c             	lea    0xc(%ebp),%eax
 587:	83 c0 04             	add    $0x4,%eax
 58a:	89 45 e8             	mov    %eax,-0x18(%ebp)
  for(i = 0; fmt[i]; i++){
 58d:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
 594:	e9 7d 01 00 00       	jmp    716 <printf+0x19f>
    c = fmt[i] & 0xff;
 599:	8b 55 0c             	mov    0xc(%ebp),%edx
 59c:	8b 45 f0             	mov    -0x10(%ebp),%eax
 59f:	01 d0                	add    %edx,%eax
 5a1:	0f b6 00             	movzbl (%eax),%eax
 5a4:	0f be c0             	movsbl %al,%eax
 5a7:	25 ff 00 00 00       	and    $0xff,%eax
 5ac:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    if(state == 0){
 5af:	83 7d ec 00          	cmpl   $0x0,-0x14(%ebp)
 5b3:	75 2c                	jne    5e1 <printf+0x6a>
      if(c == '%'){
 5b5:	83 7d e4 25          	cmpl   $0x25,-0x1c(%ebp)
 5b9:	75 0c                	jne    5c7 <printf+0x50>
        state = '%';
 5bb:	c7 45 ec 25 00 00 00 	movl   $0x25,-0x14(%ebp)
 5c2:	e9 4b 01 00 00       	jmp    712 <printf+0x19b>
      } else {
        putc(fd, c);
 5c7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 5ca:	0f be c0             	movsbl %al,%eax
 5cd:	89 44 24 04          	mov    %eax,0x4(%esp)
 5d1:	8b 45 08             	mov    0x8(%ebp),%eax
 5d4:	89 04 24             	mov    %eax,(%esp)
 5d7:	e8 c4 fe ff ff       	call   4a0 <putc>
 5dc:	e9 31 01 00 00       	jmp    712 <printf+0x19b>
      }
    } else if(state == '%'){
 5e1:	83 7d ec 25          	cmpl   $0x25,-0x14(%ebp)
 5e5:	0f 85 27 01 00 00    	jne    712 <printf+0x19b>
      if(c == 'd'){
 5eb:	83 7d e4 64          	cmpl   $0x64,-0x1c(%ebp)
 5ef:	75 2d                	jne    61e <printf+0xa7>
        printint(fd, *ap, 10, 1);
 5f1:	8b 45 e8             	mov    -0x18(%ebp),%eax
 5f4:	8b 00                	mov    (%eax),%eax
 5f6:	c7 44 24 0c 01 00 00 	movl   $0x1,0xc(%esp)
 5fd:	00 
 5fe:	c7 44 24 08 0a 00 00 	movl   $0xa,0x8(%esp)
 605:	00 
 606:	89 44 24 04          	mov    %eax,0x4(%esp)
 60a:	8b 45 08             	mov    0x8(%ebp),%eax
 60d:	89 04 24             	mov    %eax,(%esp)
 610:	e8 b3 fe ff ff       	call   4c8 <printint>
        ap++;
 615:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
 619:	e9 ed 00 00 00       	jmp    70b <printf+0x194>
      } else if(c == 'x' || c == 'p'){
 61e:	83 7d e4 78          	cmpl   $0x78,-0x1c(%ebp)
 622:	74 06                	je     62a <printf+0xb3>
 624:	83 7d e4 70          	cmpl   $0x70,-0x1c(%ebp)
 628:	75 2d                	jne    657 <printf+0xe0>
        printint(fd, *ap, 16, 0);
 62a:	8b 45 e8             	mov    -0x18(%ebp),%eax
 62d:	8b 00                	mov    (%eax),%eax
 62f:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
 636:	00 
 637:	c7 44 24 08 10 00 00 	movl   $0x10,0x8(%esp)
 63e:	00 
 63f:	89 44 24 04          	mov    %eax,0x4(%esp)
 643:	8b 45 08             	mov    0x8(%ebp),%eax
 646:	89 04 24             	mov    %eax,(%esp)
 649:	e8 7a fe ff ff       	call   4c8 <printint>
        ap++;
 64e:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
 652:	e9 b4 00 00 00       	jmp    70b <printf+0x194>
      } else if(c == 's'){
 657:	83 7d e4 73          	cmpl   $0x73,-0x1c(%ebp)
 65b:	75 46                	jne    6a3 <printf+0x12c>
        s = (char*)*ap;
 65d:	8b 45 e8             	mov    -0x18(%ebp),%eax
 660:	8b 00                	mov    (%eax),%eax
 662:	89 45 f4             	mov    %eax,-0xc(%ebp)
        ap++;
 665:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
        if(s == 0)
 669:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 66d:	75 27                	jne    696 <printf+0x11f>
          s = "(null)";
 66f:	c7 45 f4 d2 09 00 00 	movl   $0x9d2,-0xc(%ebp)
        while(*s != 0){
 676:	eb 1e                	jmp    696 <printf+0x11f>
          putc(fd, *s);
 678:	8b 45 f4             	mov    -0xc(%ebp),%eax
 67b:	0f b6 00             	movzbl (%eax),%eax
 67e:	0f be c0             	movsbl %al,%eax
 681:	89 44 24 04          	mov    %eax,0x4(%esp)
 685:	8b 45 08             	mov    0x8(%ebp),%eax
 688:	89 04 24             	mov    %eax,(%esp)
 68b:	e8 10 fe ff ff       	call   4a0 <putc>
          s++;
 690:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
 694:	eb 01                	jmp    697 <printf+0x120>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 696:	90                   	nop
 697:	8b 45 f4             	mov    -0xc(%ebp),%eax
 69a:	0f b6 00             	movzbl (%eax),%eax
 69d:	84 c0                	test   %al,%al
 69f:	75 d7                	jne    678 <printf+0x101>
 6a1:	eb 68                	jmp    70b <printf+0x194>
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 6a3:	83 7d e4 63          	cmpl   $0x63,-0x1c(%ebp)
 6a7:	75 1d                	jne    6c6 <printf+0x14f>
        putc(fd, *ap);
 6a9:	8b 45 e8             	mov    -0x18(%ebp),%eax
 6ac:	8b 00                	mov    (%eax),%eax
 6ae:	0f be c0             	movsbl %al,%eax
 6b1:	89 44 24 04          	mov    %eax,0x4(%esp)
 6b5:	8b 45 08             	mov    0x8(%ebp),%eax
 6b8:	89 04 24             	mov    %eax,(%esp)
 6bb:	e8 e0 fd ff ff       	call   4a0 <putc>
        ap++;
 6c0:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
 6c4:	eb 45                	jmp    70b <printf+0x194>
      } else if(c == '%'){
 6c6:	83 7d e4 25          	cmpl   $0x25,-0x1c(%ebp)
 6ca:	75 17                	jne    6e3 <printf+0x16c>
        putc(fd, c);
 6cc:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 6cf:	0f be c0             	movsbl %al,%eax
 6d2:	89 44 24 04          	mov    %eax,0x4(%esp)
 6d6:	8b 45 08             	mov    0x8(%ebp),%eax
 6d9:	89 04 24             	mov    %eax,(%esp)
 6dc:	e8 bf fd ff ff       	call   4a0 <putc>
 6e1:	eb 28                	jmp    70b <printf+0x194>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 6e3:	c7 44 24 04 25 00 00 	movl   $0x25,0x4(%esp)
 6ea:	00 
 6eb:	8b 45 08             	mov    0x8(%ebp),%eax
 6ee:	89 04 24             	mov    %eax,(%esp)
 6f1:	e8 aa fd ff ff       	call   4a0 <putc>
        putc(fd, c);
 6f6:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 6f9:	0f be c0             	movsbl %al,%eax
 6fc:	89 44 24 04          	mov    %eax,0x4(%esp)
 700:	8b 45 08             	mov    0x8(%ebp),%eax
 703:	89 04 24             	mov    %eax,(%esp)
 706:	e8 95 fd ff ff       	call   4a0 <putc>
      }
      state = 0;
 70b:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 712:	83 45 f0 01          	addl   $0x1,-0x10(%ebp)
 716:	8b 55 0c             	mov    0xc(%ebp),%edx
 719:	8b 45 f0             	mov    -0x10(%ebp),%eax
 71c:	01 d0                	add    %edx,%eax
 71e:	0f b6 00             	movzbl (%eax),%eax
 721:	84 c0                	test   %al,%al
 723:	0f 85 70 fe ff ff    	jne    599 <printf+0x22>
        putc(fd, c);
      }
      state = 0;
    }
  }
}
 729:	c9                   	leave  
 72a:	c3                   	ret    
 72b:	90                   	nop

0000072c <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 72c:	55                   	push   %ebp
 72d:	89 e5                	mov    %esp,%ebp
 72f:	83 ec 10             	sub    $0x10,%esp
  Header *bp, *p;

  bp = (Header*)ap - 1;
 732:	8b 45 08             	mov    0x8(%ebp),%eax
 735:	83 e8 08             	sub    $0x8,%eax
 738:	89 45 f8             	mov    %eax,-0x8(%ebp)
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 73b:	a1 3c 0c 00 00       	mov    0xc3c,%eax
 740:	89 45 fc             	mov    %eax,-0x4(%ebp)
 743:	eb 24                	jmp    769 <free+0x3d>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 745:	8b 45 fc             	mov    -0x4(%ebp),%eax
 748:	8b 00                	mov    (%eax),%eax
 74a:	3b 45 fc             	cmp    -0x4(%ebp),%eax
 74d:	77 12                	ja     761 <free+0x35>
 74f:	8b 45 f8             	mov    -0x8(%ebp),%eax
 752:	3b 45 fc             	cmp    -0x4(%ebp),%eax
 755:	77 24                	ja     77b <free+0x4f>
 757:	8b 45 fc             	mov    -0x4(%ebp),%eax
 75a:	8b 00                	mov    (%eax),%eax
 75c:	3b 45 f8             	cmp    -0x8(%ebp),%eax
 75f:	77 1a                	ja     77b <free+0x4f>
free(void *ap)
{
  Header *bp, *p;

  bp = (Header*)ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 761:	8b 45 fc             	mov    -0x4(%ebp),%eax
 764:	8b 00                	mov    (%eax),%eax
 766:	89 45 fc             	mov    %eax,-0x4(%ebp)
 769:	8b 45 f8             	mov    -0x8(%ebp),%eax
 76c:	3b 45 fc             	cmp    -0x4(%ebp),%eax
 76f:	76 d4                	jbe    745 <free+0x19>
 771:	8b 45 fc             	mov    -0x4(%ebp),%eax
 774:	8b 00                	mov    (%eax),%eax
 776:	3b 45 f8             	cmp    -0x8(%ebp),%eax
 779:	76 ca                	jbe    745 <free+0x19>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
 77b:	8b 45 f8             	mov    -0x8(%ebp),%eax
 77e:	8b 40 04             	mov    0x4(%eax),%eax
 781:	c1 e0 03             	shl    $0x3,%eax
 784:	89 c2                	mov    %eax,%edx
 786:	03 55 f8             	add    -0x8(%ebp),%edx
 789:	8b 45 fc             	mov    -0x4(%ebp),%eax
 78c:	8b 00                	mov    (%eax),%eax
 78e:	39 c2                	cmp    %eax,%edx
 790:	75 24                	jne    7b6 <free+0x8a>
    bp->s.size += p->s.ptr->s.size;
 792:	8b 45 f8             	mov    -0x8(%ebp),%eax
 795:	8b 50 04             	mov    0x4(%eax),%edx
 798:	8b 45 fc             	mov    -0x4(%ebp),%eax
 79b:	8b 00                	mov    (%eax),%eax
 79d:	8b 40 04             	mov    0x4(%eax),%eax
 7a0:	01 c2                	add    %eax,%edx
 7a2:	8b 45 f8             	mov    -0x8(%ebp),%eax
 7a5:	89 50 04             	mov    %edx,0x4(%eax)
    bp->s.ptr = p->s.ptr->s.ptr;
 7a8:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7ab:	8b 00                	mov    (%eax),%eax
 7ad:	8b 10                	mov    (%eax),%edx
 7af:	8b 45 f8             	mov    -0x8(%ebp),%eax
 7b2:	89 10                	mov    %edx,(%eax)
 7b4:	eb 0a                	jmp    7c0 <free+0x94>
  } else
    bp->s.ptr = p->s.ptr;
 7b6:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7b9:	8b 10                	mov    (%eax),%edx
 7bb:	8b 45 f8             	mov    -0x8(%ebp),%eax
 7be:	89 10                	mov    %edx,(%eax)
  if(p + p->s.size == bp){
 7c0:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7c3:	8b 40 04             	mov    0x4(%eax),%eax
 7c6:	c1 e0 03             	shl    $0x3,%eax
 7c9:	03 45 fc             	add    -0x4(%ebp),%eax
 7cc:	3b 45 f8             	cmp    -0x8(%ebp),%eax
 7cf:	75 20                	jne    7f1 <free+0xc5>
    p->s.size += bp->s.size;
 7d1:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7d4:	8b 50 04             	mov    0x4(%eax),%edx
 7d7:	8b 45 f8             	mov    -0x8(%ebp),%eax
 7da:	8b 40 04             	mov    0x4(%eax),%eax
 7dd:	01 c2                	add    %eax,%edx
 7df:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7e2:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 7e5:	8b 45 f8             	mov    -0x8(%ebp),%eax
 7e8:	8b 10                	mov    (%eax),%edx
 7ea:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7ed:	89 10                	mov    %edx,(%eax)
 7ef:	eb 08                	jmp    7f9 <free+0xcd>
  } else
    p->s.ptr = bp;
 7f1:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7f4:	8b 55 f8             	mov    -0x8(%ebp),%edx
 7f7:	89 10                	mov    %edx,(%eax)
  freep = p;
 7f9:	8b 45 fc             	mov    -0x4(%ebp),%eax
 7fc:	a3 3c 0c 00 00       	mov    %eax,0xc3c
}
 801:	c9                   	leave  
 802:	c3                   	ret    

00000803 <morecore>:

static Header*
morecore(uint nu)
{
 803:	55                   	push   %ebp
 804:	89 e5                	mov    %esp,%ebp
 806:	83 ec 28             	sub    $0x28,%esp
  char *p;
  Header *hp;

  if(nu < 4096)
 809:	81 7d 08 ff 0f 00 00 	cmpl   $0xfff,0x8(%ebp)
 810:	77 07                	ja     819 <morecore+0x16>
    nu = 4096;
 812:	c7 45 08 00 10 00 00 	movl   $0x1000,0x8(%ebp)
  p = sbrk(nu * sizeof(Header));
 819:	8b 45 08             	mov    0x8(%ebp),%eax
 81c:	c1 e0 03             	shl    $0x3,%eax
 81f:	89 04 24             	mov    %eax,(%esp)
 822:	e8 61 fc ff ff       	call   488 <sbrk>
 827:	89 45 f4             	mov    %eax,-0xc(%ebp)
  if(p == (char*)-1)
 82a:	83 7d f4 ff          	cmpl   $0xffffffff,-0xc(%ebp)
 82e:	75 07                	jne    837 <morecore+0x34>
    return 0;
 830:	b8 00 00 00 00       	mov    $0x0,%eax
 835:	eb 22                	jmp    859 <morecore+0x56>
  hp = (Header*)p;
 837:	8b 45 f4             	mov    -0xc(%ebp),%eax
 83a:	89 45 f0             	mov    %eax,-0x10(%ebp)
  hp->s.size = nu;
 83d:	8b 45 f0             	mov    -0x10(%ebp),%eax
 840:	8b 55 08             	mov    0x8(%ebp),%edx
 843:	89 50 04             	mov    %edx,0x4(%eax)
  free((void*)(hp + 1));
 846:	8b 45 f0             	mov    -0x10(%ebp),%eax
 849:	83 c0 08             	add    $0x8,%eax
 84c:	89 04 24             	mov    %eax,(%esp)
 84f:	e8 d8 fe ff ff       	call   72c <free>
  return freep;
 854:	a1 3c 0c 00 00       	mov    0xc3c,%eax
}
 859:	c9                   	leave  
 85a:	c3                   	ret    

0000085b <malloc>:

void*
malloc(uint nbytes)
{
 85b:	55                   	push   %ebp
 85c:	89 e5                	mov    %esp,%ebp
 85e:	83 ec 28             	sub    $0x28,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 861:	8b 45 08             	mov    0x8(%ebp),%eax
 864:	83 c0 07             	add    $0x7,%eax
 867:	c1 e8 03             	shr    $0x3,%eax
 86a:	83 c0 01             	add    $0x1,%eax
 86d:	89 45 ec             	mov    %eax,-0x14(%ebp)
  if((prevp = freep) == 0){
 870:	a1 3c 0c 00 00       	mov    0xc3c,%eax
 875:	89 45 f0             	mov    %eax,-0x10(%ebp)
 878:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
 87c:	75 23                	jne    8a1 <malloc+0x46>
    base.s.ptr = freep = prevp = &base;
 87e:	c7 45 f0 34 0c 00 00 	movl   $0xc34,-0x10(%ebp)
 885:	8b 45 f0             	mov    -0x10(%ebp),%eax
 888:	a3 3c 0c 00 00       	mov    %eax,0xc3c
 88d:	a1 3c 0c 00 00       	mov    0xc3c,%eax
 892:	a3 34 0c 00 00       	mov    %eax,0xc34
    base.s.size = 0;
 897:	c7 05 38 0c 00 00 00 	movl   $0x0,0xc38
 89e:	00 00 00 
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 8a1:	8b 45 f0             	mov    -0x10(%ebp),%eax
 8a4:	8b 00                	mov    (%eax),%eax
 8a6:	89 45 f4             	mov    %eax,-0xc(%ebp)
    if(p->s.size >= nunits){
 8a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8ac:	8b 40 04             	mov    0x4(%eax),%eax
 8af:	3b 45 ec             	cmp    -0x14(%ebp),%eax
 8b2:	72 4d                	jb     901 <malloc+0xa6>
      if(p->s.size == nunits)
 8b4:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8b7:	8b 40 04             	mov    0x4(%eax),%eax
 8ba:	3b 45 ec             	cmp    -0x14(%ebp),%eax
 8bd:	75 0c                	jne    8cb <malloc+0x70>
        prevp->s.ptr = p->s.ptr;
 8bf:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8c2:	8b 10                	mov    (%eax),%edx
 8c4:	8b 45 f0             	mov    -0x10(%ebp),%eax
 8c7:	89 10                	mov    %edx,(%eax)
 8c9:	eb 26                	jmp    8f1 <malloc+0x96>
      else {
        p->s.size -= nunits;
 8cb:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8ce:	8b 40 04             	mov    0x4(%eax),%eax
 8d1:	89 c2                	mov    %eax,%edx
 8d3:	2b 55 ec             	sub    -0x14(%ebp),%edx
 8d6:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8d9:	89 50 04             	mov    %edx,0x4(%eax)
        p += p->s.size;
 8dc:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8df:	8b 40 04             	mov    0x4(%eax),%eax
 8e2:	c1 e0 03             	shl    $0x3,%eax
 8e5:	01 45 f4             	add    %eax,-0xc(%ebp)
        p->s.size = nunits;
 8e8:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8eb:	8b 55 ec             	mov    -0x14(%ebp),%edx
 8ee:	89 50 04             	mov    %edx,0x4(%eax)
      }
      freep = prevp;
 8f1:	8b 45 f0             	mov    -0x10(%ebp),%eax
 8f4:	a3 3c 0c 00 00       	mov    %eax,0xc3c
      return (void*)(p + 1);
 8f9:	8b 45 f4             	mov    -0xc(%ebp),%eax
 8fc:	83 c0 08             	add    $0x8,%eax
 8ff:	eb 38                	jmp    939 <malloc+0xde>
    }
    if(p == freep)
 901:	a1 3c 0c 00 00       	mov    0xc3c,%eax
 906:	39 45 f4             	cmp    %eax,-0xc(%ebp)
 909:	75 1b                	jne    926 <malloc+0xcb>
      if((p = morecore(nunits)) == 0)
 90b:	8b 45 ec             	mov    -0x14(%ebp),%eax
 90e:	89 04 24             	mov    %eax,(%esp)
 911:	e8 ed fe ff ff       	call   803 <morecore>
 916:	89 45 f4             	mov    %eax,-0xc(%ebp)
 919:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 91d:	75 07                	jne    926 <malloc+0xcb>
        return 0;
 91f:	b8 00 00 00 00       	mov    $0x0,%eax
 924:	eb 13                	jmp    939 <malloc+0xde>
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 926:	8b 45 f4             	mov    -0xc(%ebp),%eax
 929:	89 45 f0             	mov    %eax,-0x10(%ebp)
 92c:	8b 45 f4             	mov    -0xc(%ebp),%eax
 92f:	8b 00                	mov    (%eax),%eax
 931:	89 45 f4             	mov    %eax,-0xc(%ebp)
      return (void*)(p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
 934:	e9 70 ff ff ff       	jmp    8a9 <malloc+0x4e>
}
 939:	c9                   	leave  
 93a:	c3                   	ret    
